﻿namespace WP7Contrib.Services.BingMaps.Model
{
    using Common;
    using Common.Extensions;
    using Collections;

    public class ImageryMetadataSearchResult : Result, ICloneable<ImageryMetadataSearchResult>
    {
        private ObservableCollection<Metadata> imagery;

        private int estimatedTotal;

        public ImageryMetadataSearchResult()
            : base()
        {
            this.imagery = new ObservableCollection<Metadata>();
        }

        public ObservableCollection<Metadata> Imagery
        {
            get
            {
                return this.imagery;
            }
            set
            {
                this.SetPropertyAndNotify(ref imagery, value, () => Imagery);
            }
        }

        public int EstimatedTotal
        {
            get
            {
                return this.estimatedTotal;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.estimatedTotal, value, () => this.EstimatedTotal);
            }
        }

        public ImageryMetadataSearchResult ShallowClone()
        {
            var result = new ImageryMetadataSearchResult
            {
                Imagery = this.imagery,
                EstimatedTotal = this.estimatedTotal,
            };

            result.CloneBaseResult(this);
            return result;
        }

        public ImageryMetadataSearchResult DeepClone()
        {
            var copy = new ObservableCollection<Metadata>();
            this.imagery.ForEach(i => copy.Add(i.DeepClone()));

            var result = new ImageryMetadataSearchResult
            {
                Imagery = copy,
                EstimatedTotal = this.estimatedTotal,
            };

            result.CloneBaseResult(this);
            return result;
        }
    }
}